﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Areas/Admin/Views/Shared/AdminSite.Master"
    Inherits="System.Web.Mvc.ViewPage<HYBYSoft.Company.Models.CompanyAndLinkmanRelation>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Index
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <script src="<%: Url.Content("~/Scripts/jquery-1.4.4.min.js") %>" type="text/javascript"></script>
    <script src="<%: Url.Content("~/Scripts/jquery.validate.min.js") %>" type="text/javascript"></script>
    <script src="<%: Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js") %>"
        type="text/javascript"></script>
    <div style="margin-top: 10px;">
    </div>
    <div id="content">
        <p>
            <span id="sitemap">当前位置：</span>
        </p>
        <% using (Html.BeginForm("Index", "Company"))
           { %>
        <%: Html.ValidationSummary(false) %>
        <%: Html.HiddenFor(model=>model.CompanyID) %>
        <fieldset>
            <legend>公司详细信息</legend>
            <div class="company-lable">
                <span class="span-font">
                    <%: Html.LabelFor(model => model.Name) %>:</span>
            </div>
            <div class="company-field">
                <%: Html.TextBoxFor(model => model.Name, new { @style = "width:220px;" })%>
                <%--<%: Html.ValidationMessageFor(model => model.Name) %>--%>
            </div>
            <div class="company-lableAddress">
                <span class="span-font">
                    <%: Html.LabelFor(model => model.Address) %>:</span>
            </div>
            <div class="company-field">
                <%: Html.TextBoxFor(model => model.Address, new { @style = "width:385px;" })%>
                <%--<%: Html.ValidationMessageFor(model => model.Address)%>--%>
            </div>
            <div class="editor-empty">
            </div>
            <div class="company-lable">
                <span class="span-font">
                    <%: Html.LabelFor(model => model.E_mail) %>:</span>
            </div>
            <div class="company-field">
                <%: Html.TextBoxFor(model => model.E_mail, new { @style = "width:200px;" })%>
                <%--<%: Html.ValidationMessageFor(model => model.E_mail)%>--%>
            </div>
            <div class="company-lable">
                <span class="span-font">
                    <%: Html.LabelFor(model => model.Corporation) %>:</span>
            </div>
            <div class="company-field">
                <%: Html.TextBoxFor(model => model.Corporation, new { @style = "width:110px;" })%>
                <%--<%: Html.ValidationMessageFor(model => model.Corporation)%>--%>
            </div>
            <div class="company-lableAddress">
                <span class="span-font">
                    <%: Html.LabelFor(model => model.Fax) %>:</span>
            </div>
            <div class="company-field">
                <%: Html.TextBoxFor(model => model.Fax, new { @style = "width:180px;" })%>
                <%--<%: Html.ValidationMessageFor(model => model.Fax)%>--%>
            </div>
            <div class="editor-empty">
            </div>
            <div class="company-lable">
                <span class="span-font">
                    <%: Html.LabelFor(model => model.TelFirst) %>:</span>
            </div>
            <div class="company-field">
                <%: Html.TextBoxFor(model => model.TelFirst)%>
                <%--<%: Html.ValidationMessageFor(model => model.TelFirst)%>--%>
            </div>
            <div class="company-lable">
                <span class="span-font">
                    <%: Html.LabelFor(model => model.TelSecond) %>:</span>
            </div>
            <div class="company-field">
                <%: Html.TextBoxFor(model => model.TelSecond)%>
                <%--<%: Html.ValidationMessageFor(model => model.TelSecond)%>--%>
            </div>
            <div class="company-lable">
                <span class="span-font">
                    <%: Html.LabelFor(model => model.TelThird)%>:</span>
            </div>
            <div class="company-field">
                <%: Html.TextBoxFor(model => model.TelThird)%>
                <%--<%: Html.ValidationMessageFor(model => model.TelThird)%>--%>
            </div>
            <div class="editor-empty">
            </div>
            <div class="company-lable">
                <span class="span-font">
                    <%: Html.LabelFor(model => model.Postcode) %>:</span>
            </div>
            <div class="company-field">
                <%: Html.TextBoxFor(model => model.Postcode, new { @style = "width:85px;" })%>
                <%--<%: Html.ValidationMessageFor(model => model.Postcode)%>--%>
            </div>
            <div class="company-lable">
                <span class="span-font">
                    <%: Html.LabelFor(model => model.Business)%>:</span>
            </div>
            <div class="company-field">
                <%: Html.TextAreaFor(model => model.Business, new { @style = "width:480px;" })%>
                <%--<%: Html.ValidationMessageFor(model => model.Business)%>--%>
            </div>
            <div class="editor-empty">
            </div>
            <div class="company-lable">
                <span class="span-font">
                    <%: Html.LabelFor(model => model.Type) %>:</span>
            </div>
            <div class="company-field">
                <%=Html.DropDownListFor(model => model.Type, (IEnumerable<SelectListItem>)ViewData["ddlType"], new { Style = "width:100px;margin-left:5px;" })%>
                <%--<%: Html.ValidationMessageFor(model => model.Type)%>--%>
            </div>
            <div class="company-lable">
                <span class="span-font">
                    <%: Html.LabelFor(model => model.City) %>:</span>
            </div>
            <div class="company-field">
                <%=Html.DropDownListFor(model => model.City, (IEnumerable<SelectListItem>)ViewData["ddlCity"], new { Style = "width:100px" })%>
                <%--<%: Html.ValidationMessageFor(model => model.City)%>--%>
            </div>
            <div class="company-lable">
                <span class="span-font">
                    <%: Html.LabelFor(model => model.Scale)%>:</span>
            </div>
            <div class="company-field">
                <%: Html.TextBoxFor(model => model.Scale, new { Style = "width:120px" })%>
                <%--<%: Html.ValidationMessageFor(model => model.Scale)%>--%>
            </div>
            <div class="editor-empty">
            </div>
            <div class="company-lable">
                <span class="span-font">
                    <%: Html.LabelFor(model => model.Trade) %>:</span>
            </div>
            <div class="company-field">
                <%foreach (SelectListItem l in (List<SelectListItem>)ViewData["rboListTrade"])
                  {
                      if (l.Text == Model.Trade)
                      {
                %>
                <%=Html.RadioButtonFor(model => model.Trade, l.Text,new {@checked="checked"})%><%=l.Text %>
                <%}
                      else
                      {%>
                <%=Html.RadioButtonFor(model => model.Trade,l.Text,null)%><%=l.Text %>
                <%}
                  } %>
                <%: Html.ValidationMessageFor(model => model.Trade) %>
            </div>
            <div class="editor-empty">
            </div>
            <div class="company-lable">
                <span class="span-font">
                    <%: Html.LabelFor(model => model.Honor)%>:</span>
            </div>
            <div class="company-field">
                <%: Html.TextAreaFor(model => model.Honor, new { @style = "width:665px;height:60px;" })%><br />
                <%: Html.ValidationMessageFor(model => model.Honor)%>
            </div>
            <div class="editor-empty">
            </div>
            <div class="company-lable">
                <span class="span-font">
                    <%: Html.LabelFor(model => model.Description)%>:</span>
            </div>
            <div class="company-field">
                <%: Html.TextAreaFor(model => model.Description, new { @style = "width:665px;height:60px;" })%><br />
                <%: Html.ValidationMessageFor(model => model.Description)%>
            </div>
            <div class="editor-empty">
            </div>
            <br />
            <div id="removeNext">
                <% foreach (var item in Model.Linkmen)
                   {%>
                <%= Html.Hidden("linkManId",item.LinkmanID) %>
                <% Html.RenderAction("ReadASCX", new { lid = item.LinkmanID, type = 1 }); %>
                <%} %>
            </div>
            <div id="mydiv" style="display: none">
                <%= Html.Hidden("linkManId",0) %>
                <% Html.RenderAction("ReadASCX", new { lid = 0, type = 0 }); %>
            </div>
            <div class="mdiv" id="mdiv">
            </div>
            <div id="div_UnClick" style="width: 86%; text-align: left; padding-left: 5px;">
                <a id="addLinkMan" href="javascript:void();">增加联系人</a></div>
            <span id="span_validationMessage"></span>
            <p style="text-align: center">
                <input type="submit" id="btnSubmit" value="保存信息" />
            </p>
        </fieldset>
    </div>
    <% } %>
    <div class="editor-empty">
    </div>
    <script type="text/javascript">
        $(document).ready(function () {
            bindListener();
            $("span[name='span_validationMessage']").hide();

            $("#addLinkMan").click(function () {
                $("#mdiv").append($("#mydiv").clone());
                $("#mydiv").show();
                bindListener();
            });
            $("#btnSubmit").click(function () {
                //                $("#removeNext").next().remove();
                var i = 0;
                var result = true;
                $("input[name='linkName']").each(function () {
                    if ($(this).val() == "") {
                        $(this).attr("style", "border:1px solid red; background-color:#FFEEEE");
                        $(this).next().text("*必填");
                        $(this).next().show();
                        result = false;
                    }
                    i = i + 1;
                    $(this).keyup(function () {
                        if ($(this).val() != '') {
                            $(this).next().hide();
                            $(this).removeAttr("style");
                        }
                    });
                });
                $("input[name='Tel']").each(function () {
                    if ($(this).val() == "") {
                        $(this).attr("style", "border:1px solid red; background-color:#FFEEEE");
                        $(this).next().text("*必填");
                        $(this).next().show();
                        result = false;
                    }
                    i = i + 1;
                    $(this).keyup(function () {
                        if ($(this).val() != '') {
                            $(this).next().hide();
                            $(this).removeAttr("style");
                        }
                    });
                });
            });
        });
        function bindListener() {
            $("a[name=rmlink]").unbind().click(function () {
                $(this).parents("#mydiv").remove();
            });
        }

    </script>
</asp:Content>
